package org.example.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.example.entity.CourseRating;
import org.example.mapper.CourseRatingMapper;
import org.example.service.CourseRatingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName CourseRatingServiceImpl
 * @Description TODO
 * @Author qiuye
 * @Date 2025年08月17日 20:25
 * @Version 1.0
 */
@Service
public class CourseRatingServiceImpl implements CourseRatingService {
    @Autowired
    private CourseRatingMapper courseRatingMapper;


    @Override
    public PageInfo<CourseRating> getCourseRating(int courseId, int page, int size) {
        PageHelper.startPage(page, size);
        List<CourseRating> courseRatings = courseRatingMapper.getCourseRating(courseId);
        PageInfo<CourseRating> pageInfo = new PageInfo<>(courseRatings);
        return pageInfo;
    }

    @Override
    public List<CourseRating> getAllCourseRating(int courseId) {
        List<CourseRating> allCourseRating = courseRatingMapper.getAllCourseRating(courseId);
        return allCourseRating;
    }


}
